<template>
  <!-- 生产单 -->
  <el-table :data="produceList" style="width: 100%">
    <el-table-column
      label="产品名称"
      prop="name"
      min-width="100"
    ></el-table-column>
    <el-table-column
      label="规格型号"
      prop="specification"
      min-width="100"
    ></el-table-column>
    <el-table-column label="产品数量" prop="num" width="200"></el-table-column>
    <el-table-column label="产品状态" prop="status" width="200">
      <p v-if="scope.row.status == 0">未生产</p>
      <p v-if="scope.row.status == 1" style="color: #dfaf14">生产中</p>
      <p v-if="scope.row.status == 2" style="color: #2bd814">已完成</p>
    </el-table-column>
  </el-table>
</template>

<script>
import { queryTypeByDic } from '@/utils/getData'
export default {
  name: 'produceList',
  data () {
    return {
      produceList: [],
      typeList: []
    }
  },
  props: {
    list: {
      type: Array,
      required: true,
      default: () => { return [] }
    }
  },
  watch: {
    list (val) {
      if (val) {
        this.produceList = val
        this.typeList.forEach(item => {
          this.produceList.map(q_item => {
            if (q_item.status == item.value) {
              q_item.statusName = item.name
            }
          })
        })
      }
    }
  },
  mounted () {
    this.getStatus()
  },
  methods: {
    // 获取生产单状态
    async getStatus () {
      let data = await queryTypeByDic('produceStatus')
      this.typeList = data
    }
  }
}
</script>

<style></style>